package com.wuyou.mid;

import com.wuyou.designPatterns.iterator.IteratorMain;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;

/**
 * 522. 最长特殊序列2
 */
public class FindLUSlength {

    public static void main(String[] args) {
//        String[] strs={"aabbcc", "aabbcc","c"};
        String[] strs = {"aabbcc", "aabbcc", "bc", "bcc", "aabbccc"};
        FindLUSlength findLUSlength = new FindLUSlength();
        System.out.println(findLUSlength.solu_1(strs));
    }

    public int solu_1(String[] strs) {
//        Arrays.sort(strs, new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o1.length() - o2.length();
//            }
//        });
        int ans = -1;
        for (int i = 0; i < strs.length; i++) {
            String s1 = strs[i];
            boolean check = true;
            for (int j = 0; j < strs.length; j++) {
                String s2 = strs[j];
                int l = 0, r = 0;
                if (i != j) {
                    while (l < s1.length() && r < s2.length()) {
                        if (s1.charAt(l) == s2.charAt(r)) {
                            l++;
                        }
                        r++;
                    }
                    if (l == s1.length()) {
                        check = false;
                        break;
                    }
                }
            }
            if (check) {
                ans = Math.max(ans, s1.length());
            }
        }
        return ans;
    }
}
